/*
  The libriaty allows you to use a stack of any data typem. Just define data_type variable
*/
#include <stdio.h>
#include <stdlib.h>

//construct or use your type here:
#define type int //if your type is structure replace int into: struct my_type

struct stack {
  type *data;
  struct stack *next;
};

struct stack *PUSH(struct stack *top, type *element) {
  struct stack *temp;
  
  temp = (struct stack *)malloc(sizeof(struct stack));
  temp->data = element;
  if(top == NULL) temp->next = NULL;
    else temp->next = top;
  return temp;
}
 
struct stack *POP(struct stack *top) {
  struct stack *temp;
  
  if (top == NULL) {
    return NULL;
  } else {
    if (top->next != NULL) {
      temp = top->next;
      free(top);
      return temp;
    } else {
      free(top);
      return NULL;
    }
  }
}
  
